import 'package:Smart/pages/productor007/studytest/flutter_boss/component/icon_tab.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/model/company.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/view/company_view.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/view/find_view.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/view/jobs_view.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/view/message_view.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/view/mine_view.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_boss/model/company.dart';
// import 'package:flutter_boss/view/company/company_detail.dart';
// import 'package:flutter_boss/view/company_view.dart';
// import 'package:flutter_boss/view/message_view.dart';
// import 'package:flutter_boss/view/mine_view.dart';
// import './component/icon_tab.dart';
// import 'view/jobs_view.dart';
// import 'view/find_view.dart';
// import 'package:flutter_boss/model/company.dart';

class IndexPage extends StatefulWidget{
  @override
  IndexPageState createState() => new IndexPageState();

}

const double _kTabTextSize = 11.0; //tab栏字体大小

const int INDEX_JOB = 0;
const int INDEX_Company = 1;
const int INDEX_DYNAMIC = 2;
const int INDEX_MESSAGE = 3;
const int INDEX_MINE = 4;

Color _kPrimaryColor = Color.fromARGB(255, 0, 215, 198); //tab 栏选中时的颜色

class IndexPageState extends State<IndexPage> with SingleTickerProviderStateMixin{

  int _currentIndex = 0;
  TabController _controller;
  VoidCallback onChanged;

  @override
  void initState(){
    super.initState();
    _controller = new TabController(initialIndex: _currentIndex,length:5,vsync: this);
    onChanged = (){
//      print("---------------------------------");
//      print("${this._controller.index}");
//      print("----------------------------------");
      setState((){
        _currentIndex = this._controller.index;
      });
    };
    //监听controller的变化
    _controller.addListener(onChanged);
  }

  @override
  void dispose(){
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    Company company;
    return Scaffold(
      body:TabBarView(
        children: <Widget>[
          JobsTab(),
          CompanyTab(),
          //CompanyDetail(company),
          //CompanyPage(),
          FindPage(),
          MessagePage(),
          MinePage(),
        ],
        controller: _controller,
      ),
      bottomNavigationBar: Material(
        color: Colors.white,
        child: TabBar(
          controller: _controller,
          indicatorSize: TabBarIndicatorSize.label,
          labelStyle: TextStyle(fontSize:_kTabTextSize),
          tabs: <IconTab>[
            IconTab(
              icon:_currentIndex == INDEX_JOB
                  ? "assets/images/productor007/ic_main_tab_company_pre.png"
                  : "assets/images/productor007/ic_main_tab_company_nor.png",
              text:"职位",
              color:_currentIndex == INDEX_JOB ? _kPrimaryColor:Colors.grey[900]
            ),
            IconTab(
              icon:_currentIndex == INDEX_Company
                  ? "assets/images/productor007/ic_main_tab_company_pre.png"
                  : "assets/images/productor007/ic_main_tab_company_nor.png",
              text:"公司",
              color:_currentIndex == INDEX_Company ? _kPrimaryColor:Colors.grey[900]
            ),
            IconTab(
                icon:_currentIndex == INDEX_DYNAMIC
                    ? "assets/images/productor007/ic_main_tab_find_pre.png"
                    : "assets/images/productor007/ic_main_tab_find_nor.png",
                text:"发现",
                color:_currentIndex == INDEX_DYNAMIC ? _kPrimaryColor:Colors.grey[900]
            ),
            IconTab(
                icon:_currentIndex == INDEX_MESSAGE
                    ? "assets/images/productor007/ic_main_tab_contacts_pre.png"
                    : "assets/images/productor007/ic_main_tab_contacts_nor.png",
                text:"消息",
                color:_currentIndex == INDEX_MESSAGE ? _kPrimaryColor:Colors.grey[900]
            ),
            IconTab(
                icon:_currentIndex == INDEX_MINE
                    ? "assets/images/productor007/ic_main_tab_my_pre.png"
                    : "assets/images/productor007/ic_main_tab_my_nor.png",
                text:"我的",
                color:_currentIndex == INDEX_MINE ? _kPrimaryColor:Colors.grey[900]
            ),
          ],
        ),
      ),
    );
  }
}